<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en" class="no-js">

<head>

<meta charset="utf-8">
<title>登入界面</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<!-- CSS -->
	<link href="less/Black.ico" rel="shortcut icon" />
<link rel="stylesheet" href="resourse/plugins/login/css/reset.css">
<link rel="stylesheet" href="resourse/plugins/login/css/supersized.css">
<link rel="stylesheet" href="resourse/plugins/login/css/style.css">
	<!--提示框-->
	<link href="resourse/plugins/toast/jquery.toast.css" rel="stylesheet">

</head>

<body>
<input type="hidden" name="path"     id="path"   value="<%=request.getContextPath()%>" />
	<div class="page-container">
		<h1>校友问卷系统后台 登入</h1>
		<form  id="from" onsubmit="return false;">
			<input type="text" id="username" name="username" class="username"
				placeholder="账号"  autocomplete="off" required>  <input type="password"
				name="password" id="password" class="password" placeholder="密码"  autocomplete="off" required>
			<button  id="btn_submit">登入</button>
		</form>
		<button  id="btn_regist">注册</button>
        </div>


        <!-- Javascript -->

<script src='js/jquery-2.0.3.js'></script>
    <script src="resourse/plugins/login/js/supersized.3.2.7.min.js"></script>
    <script src="resourse/plugins/login/js/supersized-init.js"></script>
	<script type="text/javascript" src="js/jquery.md5.js"></script>
	<script src="resourse/plugins/toast/jquery.toast.js"></script>
       

    </body>
<script>

	$("#btn_regist").on("click",function(){
		window.location.href=$("#path").val()+'/regist.jsp';
	});
	//登陆
	$("#btn_submit").on('click',function(){

		if($("#username").val()==""||$("#password").val()==""){
			toastAlert("error","错误","用户账号或密码不能为空!");
			return false;
		}
		//用户登陆
		$.post(
				$("#path").val()+"/login",
				{
					date : (new Date()).getTime(),
					username : $("#username").val(),
					password : $.md5($("#password").val()) ,
					//32x
				},
				function(data){
					data=$.parseJSON(data);
					if(data.data=="false"){
						toastAlert("error","错误","用户账号或密码错误!");
					}
					else {
						//window.location.href=$("#path").val()+'/jsp/test/test.jsp';
						window.location.href=$("#path").val()+'/main.jsp';
					}

				}
		)

		return false;

	});
	//  绑定  键盘 回车键==登入键
	$(document).keydown(function(event){
		if(event.keyCode == 13){  $("#btn_submit").click();  }
	});
	// 提示框事件
	function toastAlert(icon,heading,text){
		$.toast({
			heading: heading,
			text: text,
			stack: false,
			position: 'mid-center',
			showHideTransition: 'fade',
			icon: icon   // icon:error warning  success info
		})
	}
</script>
</html>

